package com.button.boot.active.comsumer;

import java.time.LocalDateTime;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import com.button.boot.active.model.User;

import net.sf.json.JSONObject;

@Component
public class Consumer2 {
    private static final Logger log = LoggerFactory.getLogger(Consumer2.class);
    
    @JmsListener(destination = "queue_string", containerFactory = "queueListenerFactory")
    public void receiveQueue(String text) {
        log.info("consumer2收到queue_string信息:{}", text);
    }

    @JmsListener(destination = "queue_user", containerFactory = "queueListenerFactory")
    public void receiveQueue(User user) {
        log.info("consumer2收到queue_user信息:{}", JSONObject.fromObject(user));
    }

    @JmsListener(destination = "topic_string", containerFactory = "topicListenerFactory")
    public void receiveTopic(String text) {
        log.info("consumer2收到topic_string信息:{}", text);
    }

    @JmsListener(destination = "topic_user", containerFactory = "topicListenerFactory")
    public void receiveTopic(User user) {
        log.info("consumer2收到topic_user信息:{}", JSONObject.fromObject(user));
    }

    @JmsListener(destination = "topic_delay", containerFactory = "topicListenerFactory")
    public void receiveDelayTopic(String text) {
        log.info("consumer2收到topic_delay_string延时信息:{},接收时间:{}", text, LocalDateTime.now());
    }
}
